//
//  RootTabBarController.m
//  TabBarDemo
//
//  Created by chenlishuang on 16/7/11.
//  Copyright © 2016年 chenlishuang. All rights reserved.
//

#import "RootTabBarController.h"
#import "RootTabBar.h"
@interface RootTabBarController ()
@end

@implementation RootTabBarController
+ (void)initialize{
    NSDictionary *attDic = @{NSForegroundColorAttributeName:[UIColor blackColor]};
    [[UITabBarItem appearance]setTitleTextAttributes:attDic forState:UIControlStateNormal];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    RootTabBar *tabBar = [[RootTabBar alloc]init];
    [self setValue:tabBar forKey:@"tabBar"];
    [tabBar.measureBtn addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
//    [self.tabBar setBackgroundImage:[UIImage imageNamed:@"BG4_HomePage_BottomBarBackgroundImage"]];
    [self setChildViewController:[[UIViewController alloc]init] titleName:@"进度" selectedImage:@"BG4.0_HomePage_BottomBarProgressSelected" imageName:@"BG4.0_HomePage_BottomBarProgressNormal"];
    [self setChildViewController:[[UIViewController alloc]init] titleName:@"历史" selectedImage:@"BG4.0_HomePage_BottomBarHistorySelected" imageName:@"BG4.0_HomePage_BottomBarHistoryNormal"];
    [self setChildViewController:[[UIViewController alloc]init] titleName:@"学习" selectedImage:@"BG4_Learn_Selected" imageName:@"BG4_Learn_normal"];
    [self setChildViewController:[[UIViewController alloc]init] titleName:@"设置" selectedImage:@"BG4.0_HomePage_BottomBarSettingsSelected" imageName:@"BG4.0_HomePage_BottomBarSettingsNormal"];
    
}

- (void)setChildViewController:(UIViewController *)viewController titleName:(NSString *)titleName selectedImage:(NSString *)selectedImage imageName:(NSString *)imageName{
    viewController.tabBarItem.title = titleName;
    viewController.tabBarItem.image = [UIImage imageNamed:imageName];
    viewController.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    viewController.view.backgroundColor = [UIColor colorWithRed:arc4random()%255/256.0 green:arc4random()%255/256.0 blue:arc4random()%255/256.0 alpha:1];
    [self addChildViewController:viewController];
}
- (void)clickBtn{

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
